import java.sql.*;
public class Test2 {
    public static void main(String args[]) {
        Connection con=null;
        Statement sql;
        ResultSet rs;
        try{  Class.forName("com.mysql.jdbc.Driver"); //加载JDBC_MySQL驱动
        }
        catch(Exception e){}
        String uri = "jdbc:mysql://localhost:3306/world?useSSL=true";
        String user ="root";
        String password ="";
        try{
            con = DriverManager.getConnection(uri,user,password); //连接代码
        }
        catch(SQLException e){ }
        try {
            String c1=" Region ='Middle East'";
            String sqlStr="select * from country where "+c1+"";
            sql=con.createStatement();
            rs=sql.executeQuery(sqlStr);
            long sum=0;
            while(rs.next()) {
                int  Population=rs.getInt(7);
                sum+=Population;
            }
            System.out.println(sum);
            con.close();
        }
        catch(SQLException e) {
            System.out.println(e);
        }
    }
}
